<template>
  <view class="page_root" data-page-name="会议纪要查看" data-page-identification="p_1bhr43ller">
    <!-- UNI_APP_EXEGESIS_START NAVIGATION_TEMPLATE UNI_APP_EXEGESIS_END -->
    <!-- begin vid_gssy3hr0ey 自定义模板_na6lwhhanm -->
    <!-- 视频弹窗 -->

    <view class="body">
      <view class="base-data">
        <view class="img"></view>
        <view class="right-content">
          <view class="content-top">{{ state.detailData.meetingName }}</view>
          <view class="content-bottom">
            <view>{{ state.detailData.recorder||'--' }}</view>
            <view class="line"></view>
            <view>{{ state.detailData.meetingDate }}</view>
          </view>
        </view>
      </view>
      <view class="main">
        <view class="title">会议总结</view>
        <view class="box">{{ state.detailData.summary || '--' }}</view>
        <view class="title">标签</view>
        <view
          class="item-icon"
          v-if="state.detailData.labelList && state.detailData.labelList.length > 0"
        >
          <!-- stageNameList 标签，使用 colorList[1] -->
          <template v-if="state.detailData.labelList && state.detailData.labelList.length > 0">
            <view v-for="(tag, index) in state.detailData.labelList" class="label-item">
              <view class="label-img">#</view>{{ tag }}
            </view>
          </template>

          <template v-else>无</template>
        </view>
        <view class="title">参会人</view>
        <view class="box bold">{{ state.detailData.participants || '--' }}</view>
        <view class="title">外部参会人</view>
        <view class="box bold">{{ state.detailData.outParticipants || '--' }}</view>
        <view class="title">视频</view>
        <view
          class="box"
          v-if="state.detailData.videoLinks && state.detailData.videoLinks.length > 0"
        >
          <video
            v-for="(link, linkIndex) in state.detailData.videoLinks"
            :key="linkIndex"
            :src="link"
            controls
            style="width: 100%; max-height: 400px; border-radius: 8px"
          ></video>
         
        </view>
        <view class="box" v-else>--</view>
      </view>
      <view class="bottom-btn">
        <u-button
          :disabled="completeDisabled"
          block
          type="primary"
          class="bc-btn"
          @click="handleRedirect(`/pages/Page3000001047/Page3000001047?id=${state.detailId}`)"
          >问题行动项(完成进度：{{ state.detailData.progress }})</u-button
        >
      </view>
    </view>
    <!-- end vid_gssy3hr0ey 自定义模板_na6lwhhanm -->
  </view>
</template>
  <script setup>
import {
  ref,
  reactive,
  toRaw,
  markRaw,
  watch,
  computed,
  onBeforeMount,
  onMounted,
  onBeforeUnmount,
  onUnmounted,
  onActivated,
  onDeactivated,
  getCurrentInstance,
} from 'vue';
import { useRoute } from 'vue-router';
const route = useRoute();
import { handleRedirect } from '@/utils/common';
import { get, post, put, del, request, requestWithHeaders } from '@/utils/http/Axios';
// import { cloneDeep, localGet, traversalTreeStructure, set, checkCaseCondition, throttle, merge, debounce, getGridStyle, getCellRenderAble, formulaStrategy, getComponentParamsValue, get as lodashGet } from '@/utils/index';
// import { isEqual, isNullOrEmpty, isEmptyArr, isArray, isEmpty, isNullOrUnDef, isContained } from '@/utils/is';
// import { CovertOptions, getChartsDataSourceConvert } from '@/utils/chart';
// import { propertyFormatByNumber, propertyFormatByPercentage, propertyFormatByDate, parseSubFromDataList } from '@/utils/format';
// import { checkCommonCondition, getResultByCurrentCommonCondition } from '@/utils/formCondition';
// import { FormFormat } from '@/utils/formFormat'
import { customAddWaterMarkFunc, generateWaterMarkText } from '@/utils/addWaterMark';
// import dayjs from 'dayjs';
// import hashSum from 'hash-sum';
/*** UNI_APP_EXEGESIS ***
    import { handleRedirect, permission, parseJson } from '@/utils/common';
    import { onPullDownRefresh, onLoad, onReady, onShow, onHide, onPageScroll, onUnload } from '@dcloudio/uni-app';
    import { BroadcastMessage } from '@/utils/BroadcastMessage';
    import { sendToken } from "@/hooks/useIframeToken";
    *** UNI_APP_EXEGESIS ***/

// ---------------------------- 属性定义 ----------------------------
const sourceId = 'page3000001044';

// 获取传入的流程ID和组件参数
const props = defineProps({
  processInstanceId: {
    type: [String, Number, Boolean],
    default: undefined,
  },
  hideNav: {
    type: [Boolean],
    default: undefined,
  },
});

// 组件参数默认值
const componentParamsDefaultProps = {};

// 是否显示菜单按钮
const isMenuIconShow = false;
// NAVIGATION_MENU
const handleShowNavigation = () => {};

let isProcessState = ref(false);

const setTimeOutList = [];

const vid_gssy3hr0ey_props = reactive({
  code: '',
});

// ============================ 属性定义 ============================

// ---------------------------- 元素数据引用 ----------------------------
// 组件 自定义模板_na6lwhhanm ref 的引用
const vid_gssy3hr0ey_ref = ref(null);
// 动态key的map
const fieldTypeMap = {};
// 动态key的map
const refMap = { vid_gssy3hr0ey_ref };

const showState = reactive({
  vid_gssy3hr0ey_visible: true,
});
// ============================ 元素数据引用 ============================

// ---------------------------- 数据 ----------------------------

// ============================ 数据 ============================

// ---------------------------- 方法 ----------------------------
// ---------------------------- 页面数据 ----------------------------

// ============================ 页面数据 ============================

// ---------------------------- 数据字典 ----------------------------

// ============================ 数据字典 ============================

// ---------------------------- 响应 ----------------------------

// ============================ 响应 ============================

// ---------------------------- 函数 ----------------------------

// 自定义函数 返回上一页
const customFunction_goBack_aicoipqknc = (params) => {
  uni.navigateBack();
};

// ============================ 函数 ============================

// ---------------------------- 页面参数 ----------------------------

const pageParameter_state = reactive({
  processInstanceId: undefined,
});

// ============================ 页面参数 ============================

// ---------------------------- 组件事件处理方法 ----------------------------

// ============================ 组件事件处理方法 ============================

// ============================ 方法 ============================

// ---------------------------- 生命周期 ----------------------------
/*** UNI_APP_EXEGESIS ***
        // 获取上一层传递的数据
        const workflowChannel = new BroadcastMessage('WORKFLOW');
        workflowChannel.publish({ status: 'Ready' });
        workflowChannel.subscribe((data) => {
          if (data) {
            isProcessState.value = (window.self !== window.parent && data.type === 'hideHeader');
          }
        });
        *** UNI_APP_EXEGESIS ***/

const pageScrollTop = ref(0);

// *** PREVIEW_EXEGESIS ***
onMounted(() => {
  setPageParams(route.query);
  // 设置表单的rule
  try {
  } catch {
    // do nothing
  }
});
// *** PREVIEW_EXEGESIS *** //

/*** UNI_APP_EXEGESIS ***
    const routeOption = ref({})
    onLoad((option) => {
      routeOption.value = option;
    });
    onReady(() => {
      setPageParams(routeOption.value)
      // 设置表单的rule
      try{
  
      }catch{
          // do nothing
      }
    });
    // 图表刷新标记
    const uChartsReshowFlag = ref(false);
    onHide(() => { // 页面隐藏后标记置为false(如果不置为false无法触发图表更新)
        uChartsReshowFlag.value = false
    })
    onShow(() => {
        uChartsReshowFlag.value = true; // 页面激活后,标记置为true
  
        setPageParams(routeOption.value)
    })
    onPageScroll(e => {
        pageScrollTop.value = e.scrollTop
    });
    *** UNI_APP_EXEGESIS ***/

let setPageParams = (routerParam) => {
  const pageParams = [{ dataType: 'STRING', name: 'processInstanceId' }];
  const strategyMap = {
    STRING: (param, paramValue) => {
      pageParameter_state[param.name] = paramValue;
    },
    BOOLEAN: (param, paramValue) => {
      if ('true' === (paramValue || '').toLowerCase()) {
        pageParameter_state[param.name] = true;
      } else if ('false' === (paramValue || '').toLowerCase()) {
        pageParameter_state[param.name] = false;
      } else {
        // TODO: 是否要支持toast
        console.error('参数传入错误！类型不匹配！');
      }
    },
    NUMBER: (param, paramValue) => {
      if (!isNaN(paramValue)) {
        pageParameter_state[param.name] = Number(paramValue);
      } else {
        // TODO: 是否要支持toast
        console.error('参数传入错误！类型不匹配！');
      }
    },
    ARRAY: (param, paramValue) => {
      if (isNullOrUnDef(paramValue) || !paramValue || paramValue === 'undefined') {
        // default value
        pageParameter_state[param.name] = [];
      } else if (paramValue.trim().startsWith('[') && paramValue.trim().endsWith(']')) {
        try {
          pageParameter_state[param.name] = JSON.parse(decodeURI(paramValue));
        } catch (error) {
          console.error('参数解析失败 ', error);
        }
      } else {
        console.error('参数传入错误！类型不匹配！');
      }
    },
  };
  pageParams.forEach((param) => {
    strategyMap[param.dataType](param, routerParam[param.name]);
  });
};

onUnmounted(() => {
  // 销毁定时器
  setTimeOutList.forEach(({ repeat, timer }) => {
    repeat ? clearInterval(timer) : clearTimeout(timer);
  });
});

/*** UNI_APP_EXEGESIS ***
    onPullDownRefresh(() => {
      // 下拉刷新
      setTimeout(() => {
          uni.stopPullDownRefresh()
      }, 1000)
    })
    *** UNI_APP_EXEGESIS ***/

// ============================ 生命周期 ============================

// ---------------------------- 数据关联处理 ----------------------------
// ---------------------------- 组件数据同步 ----------------------------

// ============================ 组件数据同步 ============================
//
// ============================ 数据关联处理 ============================

// ---------------------- 不同组件自定义的处理逻辑 ---------------------

// ====================== 不同组件自定义的处理逻辑 ======================

// ================================定制化逻辑========================================
onMounted(() => {
  try {
    // recordForm?.value?.setRules(state.rules);
    let appDiv = document.querySelector('#app');
    appDiv.style.background = 'linear-gradient(180deg, #E1EFFD 100%, #ffffff 0%)';
    let topHeader = document.querySelector('.uni-page-head');
    if (topHeader) topHeader.remove();
    const queryString = window.location.search;

    // 使用 URLSearchParams 解析参数字符串
    const urlParams = new URLSearchParams(queryString);
    // 获取特定参数的值
    const id = urlParams.get('id');
    state.detailId = id;
    getData();
  } catch {
    // do nothing
  }
});
const state = reactive({
  detailId: undefined,
  detailData: {},
  videoPopupVisible: false,
  currentVideoUrl: '',
});
function getData() {
  get(`/solution-ppm/api/v2/built-in-system-ppm/meeting_minutes/${state.detailId}`).then((data) => {
    if (data.code !== 200) {
      uni.showToast({
        title: data.message,
        icon: 'error',
      });
      return;
    }
    state.detailData = data.data;
  });
}
function showVideo(url) {
  state.currentVideoUrl = url;
  state.videoPopupVisible = true;
}
</script>
  <style lang="less" scoped>
.page_root {
  min-height: 100%;
  box-sizing: border-box;
  overflow: auto;
}
.body {
  padding: 15px;
  padding-top: 0;
  background-image: linear-gradient(180deg, #3575c7 0%, #e1effd 100%);
  height: calc(100vh - 50px);
  overflow: auto;
}
.main {
  padding: 12px 15px;
  background: #ffffff;
  border-radius: 4px;
}

.base-data {
  padding: 15px 0;
  display: flex;
  gap: 10px;
  align-items: center;
}
.img {
  height: 40px;
  width: 40px;
  flex-shrink: 0; /* ✅ 不允许被压缩 */
  background-image: url('http://10.40.0.33:9001/file-storage/506958525295454208-source.png');
  background-size: cover;
  background-position: center;
}
.right-content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.content-top {
  font-size: 16px;
  color: #ffffff;
  font-weight: 600;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}
.content-bottom {
  display: flex;
  gap: 8px;
  font-size: 14px;
  color: #ffffff;
  text-align: center;
  font-weight: 400;
  align-items: center;
}
.line {
  height: 14px;
  width: 1px;
  background-color: #fff;
}
.title {
  font-size: 14px;
  color: #262626;
  font-weight: 600;
  margin-bottom: 8px;
}
.box {
  background: #ffffff;
  border-radius: 2px;
  min-height: 32px;
  flex: 1; /* 让输入框占满剩余空间 */
  white-space: pre-wrap; /* 保留换行和缩进 */
  margin-bottom: 10px;
}
.item-icon {
  display: flex;
  flex-wrap: wrap;
  gap: 8px; /* 可选：让 tag 之间有间距 */
  margin-bottom: 16px;
}
.label-item {
  display: flex;
  background-color: #eeeeee;
  align-items: center;
  padding: 1px 8px;
  font-size: 14px;
  color: #595959;
  letter-spacing: 0;
  text-align: center;
  font-weight: 400;
  gap: 4px;
  border-radius: 2px;
  height: 22px;
}
.bold {
  font-size: 14px;
  color: #262626;
  font-weight: 400;
}
.link-div a {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bottom-btn {
  position: absolute;
  justify-content: space-between;
  bottom: -40px;
  width: calc(100% - 30px);
}
</style>
  